/* data */
import Column from '@model/types/Column'
import Field from '@model/entity/Field'
import BizListViewData from '@src/component/business/BizListView/BizListViewData'
/* enum */
import AuthEnum from '@model/enum/AuthEnum'
/* model */
import RootWindowInitData from '@model/interface/initData/RootWindowInitData'
/* util */
import { getRootWindowInitData } from '@src/util/window'

class BizListViewComputed<T, P> extends BizListViewData<T, P> {
  
  /** 
   * @description 高级搜索列
  */
  get advanceSearchColumn(): Field[] {
    return []
  }
  
  /**
   * @description: 是否允许导出
   * @return {boolean}
   */
  get allowExport(): boolean {
    return Boolean(this.auth?.[AuthEnum.TASK_EXPORT])
  }
  
  /**
   * @description: 是否批量派单
   * @return {boolean}
   */
  get allowBatchDispatch(): boolean {
    return Boolean(this.auth?.[AuthEnum.TASK_BATCH_DISPATCH])
  }
  
  /**
   * @description: 是否允许删除
   * @return {boolean}
   */
  get allowDelete(): boolean {
    return false
  }
  
  /**
   * @description: 是否允许编辑全部
   * @return {boolean}
   */
  get allotEditAll(): boolean {
    return false
  }
  
  /**
   * @description: 导出的列数据
   * @return {Column[]}
   */
  get exportColumns(): Column[] {
    return (
      this.columns.map(column => {
        // 添加 export 属性，供导出组件使用
        column.export = true
        return column
      })
    )
  }
  
  /**
   * @description: 获取根窗口初始化数据
   * @return {RootWindowInitData} 根窗口初始化数据
   */  
  get rootWindowInitData(): RootWindowInitData {
    return getRootWindowInitData()
  }
  
  get selectedIds() {
    return this.multipleSelection.map(selectedItem => selectedItem?.id)
  }

  get computedExportStorageKey() {
    const key = this.currentTaskType?.id ? `${this.exportStorageKey}_${this.currentTaskType.id}` : this.exportStorageKey;
    return key
  }
}

export default BizListViewComputed
